// Problem: 
// Contest: 
// URL: 
// Memory Limit: 
// Time Limit: 
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define pre(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)
//const int N,mod;
inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
void solve()
{
	int n;
	cin>>n;
	vector<int> v(n+1);
	rep(i,1,n)
	{
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	int Z=0;
	map<int,int> m;
	bool f=0;
	rep(i,1,n)
	{
		m[v[i]]++;
		if(i+1>n||v[i]!=v[i+1])
		{
			if(Z==m[v[i]])f=1;
			if(Z<m[v[i]])
			{
				Z=m[v[i]];
				f=0;
			}
		}
	}
	if(Z==1)
	{
		rep(i,1,n)
		{
			if(i+1>n||v[i]!=v[i+1])
			{
				m[v[i]+1]=1;
				m[v[i]-1]=1;
			}
		}
		for(auto x:m)
		{
			if(x.first!=0)
			{
				cout<<x.first<<" ";
			}
		}
	}
	else if(Z==2)
	{
		for(auto x:m)
		{
			
			if((x.second==Z-1&&(m[x.first+1]||m[x.first-1])))
			{
				cout<<x.first<<" ";
			}
			if(m[x.first]&&m[x.first+2])
			{
				cout<<x.first+1<<" ";
				m[x.first+1]=-1;
			}
			if(x.second==Z)
			{
				if(x.first-1&&!m[x.first-1]&&!f)cout<<x.first-1<<" ";
				cout<<x.first<<" ";
				if(!m[x.first+1]&&!f)cout<<x.first+1<<" ";
			}
		}
	}
	else 
	{
		for(auto x:m)
		{
			if(x.second==Z||(x.second==Z-1&&(m[x.first+1]||m[x.first-1]))
			||(f==0&&x.second==Z-2&&(m[x.first+1]==Z||m[x.first-1]==Z)))
			{
				cout<<x.first<<" ";
			}
		}
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}
